Today's high performance interactive display systems (e.g. personal computers and workstations) require specialized graphics assist hardware, or complex three-dimensional (3-D) rendering programs, to generate realistic, animated 3-D images. Essentially, the graphics task is to convert an image, stored as an abstract representation of primitive shapes, and render that image as a realistic scene on a computer display. The graphics problem is to do it with dispatch. Shown in FIG. 1 is a block diagram 10 illustrating a known process for rendering realistic, animated three-dimensional (3-D) images. The process consists of five major steps, and is computationally intensive. Depending upon the system, some of the process steps may be performed in software, with the remainder being performed using graphics assist hardware. An image is typically represented as a group of mathematically described objects specified by shape, coordinates, surface properties, and color values. In the first step, the viewpoint transformation process 11, the objects must undergo a series of mathematical transformations (matrix multiplications) to orient the objects in space relative to the viewer, scale them to the right size, adjust for perspective foreshortening, and clip to the desired display volume. Coordinates are almost exclusively maintained and manipulated as floating point numbers.
In the second step, the lighting process 12, lighting models define the lighting to be applied to the image. In this step, ambient, diffuse, and specular lighting models can be applied to the image. Surface detail polygons may be added to simulate texture. Color and lighting information is resolved to a RGB triple at each polygon vertex which specifies the component intensities of the three additive primary colors, red, green, and blue. Normally these component intensities are "fixed point values".
During the shading process 13, the third step, the image must be clipped, projected into two-dimensions, and mapped from image coordinate space to display coordinates. Accordingly, the image is flattened, or decomposed, into simple triangles or scan aligned trapezoids. Shading algorithms are applied to make polygon facets appear solid, to smooth polygonally approximated surfaces, and to convert polygons to an array of pixels suitable for display on a raster scan display device. Color values are interpolated from vertex normals by averaging surface normals of adjacent polygon facets. Then, either linear intensity (Gouraud) or normal-vector (Phong) interpolation is performed to shade each polygon. Color slope for each scan line crossing the polygon is computed and used to calculate the color of each pixel on the scan line internal to the polygon. The "color" of each pixel is stored as a triple--one channel for each of the three additive primary colors, red, green, and blue. As pixels are computed, depth information is applied to remove hidden surfaces using various algorithms such as Z-buffering. Anti-aliasing corrections may also be applied to remove discrete-pixel spatial sampling errors which cause object edges to appear jagged.
Three types of shading are commonly used: constant shading, Gouraud shading, and Phong shading. The computational complexity of the constant shading algorithm is less than that of Gouraud and Phong. The image quality of constant shading is inferior to that of Gouraud and Phong, since the constant shading algorithm generates flat looking images with visible facets. The Gouraud shading algorithm provides a marked improvement in the image quality. The Gouraud algorithm is a "scan-line" algorithm which uses linear interpolation to compute the color of the first and last pixel on each scan line crossing the polygon. The linear interpolation requires a high level of computation complexity, thus, making Gouraud shading a prime candidate for use in hardware graphics accelerators. The Phong shading algorithm provides an even higher image quality, but the algorithm is even more computationally difficult, and requires substantial amounts of special hardware to make execution of the algorithm fast enough for continuous use in high resolution interactive displays. Consequently, Phong shading is primarily used in applications requiring high quality output, such as film generation, which allow a trade-off between time and image quality.
Image processing 14 occurs during the fourth step to facilitate both convenient and efficient manipulation of individual objects in a scene independently. In order to accomplish independent manipulation of individual objects, a mechanism is provided for placing one object on top of another. The algorithm must handle the images correctly in the case of transparency, and must blend object edges smoothly (anti-aliasing). For example, if a foreground object is rotated, it is more efficient to simply re-render that object than the entire scene. This is accomplished using compositing algorithms, capable of smoothly blending multiple images. Such algorithms are also capable of accurately rendering the effect of object transparency. Typically, image compositing algorithms utilize a fourth channel, called alpha (.alpha.), which is appended to the three (RGB) color channels of each pixel. The value of alpha specifies the percentage of a pixel covered by an object. Using, alpha, the net contribution of a foreground and background object can be computed by interpolation to give a composite color value.
The image is displayed in the final step, image display 15. As the color of each pixel is computed, it is stored in memory as an array of pixels or displayed on the screen by writing it into the frame buffer. The image must be transferred to and from the display system's frame buffer within the context of the governing windowing system. Fast Bit Block Transfers (bitblt), area fills, line drawing algorithms are required to rapidly move images between memory and the frame buffer. Once pixels are placed into the frame buffer, specialized display system hardware constantly scans the frame buffer in sync with the cathode ray tube's (CRT's) raster scan using the pixel data stored in the frame buffer to modulate the intensity of the CRT's red, green, and blue electron guns, and thereby forming the image on the screen. Thus, an important graphics task is to convert an image stored as an object description into a raster image in a pixel array in memory (or a frame buffer). Essentially, the electron beam(s) intensity is modulated by the data read from the frame buffer in sync with the raster scan, to create a visible image on the screen.
Typically, graphics display systems use three different frame buffer styles: 32-bit true color, 16-bit dithered true color, and 8-bit pseudocolor. The 32-bit true color format is used for high quality displays in the hi-end personal computer and workstation applications. Typically 8-bits are used for each of the three (RGB) color channels and stored packed in a single 32-bit word. The 16-bit dithered true color is used for medium cost color displays, wherein 4-5 bits are used for each of the three (RGB) color channels and two pixels are stored for each 32-bit word. The 8-bit pseudocolor frame buffer system is used for low-end color and high-end grayscale displays. Generally, in the pseudocolor frame buffer, 8-bits per pixel are used, and four pixels are stored in a 32-bit word.
Microprocessors having high performance floating point capabilities may be used to rapidly perform viewpoint transformation and lighting calculations on complex images. In addition, microprocessors with flexible data manipulations and high data throughput can efficiently run the algorithms (e.g. bitblt) necessary to achieve good display system performance. The shading, raster conversion, and image processing phases of the problem, however, are computation intensive and require hardware support beyond that found in most conventional microprocessors to achieve good interactive performance. Generally, 3-D graphics rendering programs on general purpose microprocessors use "constant" shading algorithms to avoid the more computationally intensive algorithms; however, these microprocessors generate inferior images to Gouraud and Phong shading. Typically, special purpose image rendering hardware is very expensive, and is difficult to integrate into a system.
Three dimensional objects are stored with all facets completely specified to allow the object to be viewed from any position in space. When the object is rendered for display, the objects are transformed into a set of polygons and drawn in an image buffer. While rendering the object, it is necessary to prevent the hidden surfaces of the object from being displayed in the final image. A technique commonly used for removing hidden surface in the final image is Z-buffering. A Z-buffer is an array, similar to the pixel array, which is used to hold the Z-value for each pixel in the image. A Z-value represents the Z-axis depth (coordinate) of a pixel. When a pixel is drawn into the image array, the Z-value of the new pixel is compared to the Z-value of the pixel currently in the image array. If the new pixel is closer to the viewer than the currently displayed pixel, the intensity values for that pixel are stored in the frame buffer, and the associated Z-value is placed in the Z-buffer. Conversely, if the new pixel is farther away from the viewer than the currently displayed pixel, the new pixel is not stored. Thus, only the surfaces closest to the viewer are displayed on the screen.
Today's Z-buffers typically hold 16-bit integer Z-values; however, 16-bit Z-values often do not have sufficient dynamic range to accurately delineate close foreground objects and distant backgrounds. Consequently, the graphics industry is moving toward higher precision Z-values, such as 32-bit integers or floating point numbers. Since 3-D graphics rendering algorithms are computationally intense, it is desirable to provide graphics instructions, for use in a conventional microprocessor, to accelerate the performance of the microprocessor during the shading, and image processing phases.